/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.delaphone.flocash.web.action;

import com.delaphone.flocash.service.UserService;
import com.delaphone.flocash.web.util.Validate;

/**
 *
 * @author tamdx
 */
public class ActiveUserAction extends BaseAction {

    private String code;
    private UserService userService;

    @Override
    public String execute() {
        validateFields();
        if (getActionErrors().size() > 0) {
            return INPUT;
        }
        if (userService.activeUser(code)) {
            return SUCCESS;
        } else {
            addActionError(getText("email.registration.warn"));
            return INPUT;
        }
    }

// <editor-fold defaultstate="collapsed" desc="set and get method">
    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public UserService getUserService() {
        return userService;
    }

    public void setUserService(UserService userService) {
        this.userService = userService;
    }// </editor-fold>

    //validate fields
    public void validateFields() {
        if (Validate.isEmptyString(code)) {
            addActionError(getText("join.code.null"));
        }
    }
}
